﻿package framework.custom;

import framework.core.*;

public class UIManager
{

	public static String addListHeadTitleStart(String text,int width) throws Exception
	{
		String ret =
			"<TABLE id=Table7 cellSpacing=0 cellPadding=0 width=98% align=center border=0>"
				+ "<TBODY>"
				+ "	<TR>"
				+ "		<TD align=left>"
				+ "			<TABLE id=Table8 cellSpacing=0 cellPadding=0 border=0 width=100%>"
				+ "				<TBODY>"
				+ "					<TR>"
				+ "					<TD bgColor=#284f7a colSpan=3>"
				+ "					<TD></TD>"
				+ "					<TR>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD>"
				+ "					<TD align=left width="
				+ width 
				+" bgColor=#ececec height=22>&nbsp;<IMG src='" + Config.getFrameworkPath() + "/images/list/d.gif' width=15 height=13> "
				+ text
				+ "&nbsp; </TD>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD>"
				+ "                 <TD align=right> ";

		return ret;
	}
	
	public static String addListHeadTitleEnd() throws Exception
	{
		String ret =
				"                 	</TD> "
				+ "                 </TR> "
				+ "				</TBODY>"
				+ "			</TABLE>"
				+ "		</TD>"
				+ "	</TR>"
				+ "</TBODY>"
				+ "</TABLE>";
		return ret;
	}

	public static String addListHeadTitle(String text) throws Exception
	{
		String ret =
			"<TABLE id=Table7 cellSpacing=0 cellPadding=0 width=98% align=center border=0>"
				+ "<TBODY>"
				+ "	<TR>"
				+ "		<TD align=left>"
				+ "			<TABLE id=Table8 cellSpacing=0 cellPadding=0 border=0>"
				+ "				<TBODY>"
				+ "					<TR>"
				+ "					<TD bgColor=#284f7a colSpan=3>"
				+ "					<TD></TD>"
				+ "					<TR>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD>"
				+ "					<TD bgColor=#ececec height=22>&nbsp;<IMG src='" + Config.getFrameworkPath() + "/images/list/d.gif' width=15 height=13> "
				+ text
				+ "&nbsp; </TD>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD>"
				+ "                 </TR> "
				+ "				</TBODY>"
				+ "			</TABLE>"
				+ "		</TD>"
				+ "	</TR>"
				+ "</TBODY>"
				+ "</TABLE>";

		return ret;
	}
		
	public static String addListHeadTitle(String text, String style) throws Exception
	{
		String ret =
			"<TABLE id=Table7 cellSpacing=0 cellPadding=0 width=98% align=center border=0>"
				+ "<TBODY>"
				+ "	<TR>"
				+ "		<TD align=left>"
				+ "			<TABLE id=Table8 cellSpacing=0 cellPadding=0 border=0>"
				+ "				<TBODY>"
				+ "					<TR>"
				+ "					<TD bgColor=#284f7a colSpan=3>"
				+ "					<TD></TD>"
				+ "					<TR>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD>"
				+ "					<TD bgColor=#ececec height=22 "+style+">&nbsp;<IMG src='" + Config.getFrameworkPath() + "/images/list/d.gif' width=15 height=13> "
				+ text
				+ "&nbsp; </TD>"
				+ "					<TD width=1 bgColor=#284f7a>"
				+ "					<IMG src='" + Config.getFrameworkPath() + "/images/list/spacer.gif' width=1 height=1></TD></TR>"
				+ "				</TBODY>"
				+ "			</TABLE>"
				+ "		</TD>"
				+ "	</TR>"
				+ "</TBODY>"
				+ "</TABLE>";

		return ret;
	}
	//	数据编辑标题
	public static String addEditHeadTitle(String text) throws Exception
	{
		String ret =
			" <table width=98% cellpadding=0 cellspacing=0 border=0 align=center>"
				+ "<tr><td align=left>"
				+ "	<table cellpadding=0 cellspacing=0 border=0>"
				+ "	<tr>"
				+ "	<td colspan=3 bgcolor=#284F7A><img src=" + Config.getFrameworkPath() + "/images/edit/spacer.gif height=1><td>"
				+ "	</tr>"
				+ "<tr>"
				+ "<td width=1 bgcolor=#284F7A>"
				+ "<img src=" + Config.getFrameworkPath() + "/images/edit/spacer.gif width='1' height='1'></td>"
				+ "<td align=center bgcolor=#ECECEC height=22>"
				+ "	&nbsp;"
				+ "	<img src=" + Config.getFrameworkPath() + "/images/edit/menu_icon.gif width=13 height=7>"
				+ text
				+ "	&nbsp;"
				+ "</td>"
				+ "<td width=1 bgcolor=#284F7A>"
				+ "<img src=" + Config.getFrameworkPath() + "/images/edit/spacer.gif width='1' height='1'></td>"
				+ "</tr>"
				+ "	</table>"
				+ "</td></tr>"
				+ "</table>";
		return ret;
	}
	//数据列表表头
	public static String addListHeadLeft(String text, int colIndex)
			throws Exception
	{
		String ret = "<td align=left>&nbsp;" + text + "</td>";
		return ret;
	}
	public static String addListHeadLeft(String text, int colIndex,String noUse)
				throws Exception
	{
		String ret = "<td align=left>&nbsp;" + text + "</td>";
		return ret;
	}
		
	public static String addListHeadRight(String text, int colIndex)
				throws Exception
	{
		String ret = "<td align=right>" + text + "&nbsp;</td>";
		return ret;
	}
	public static String addListHeadRight(String text, int colIndex,String noUse)
					throws Exception
	{
		String ret = "<td align=right>" + text + "&nbsp;</td>";
		return ret;
	}	
	
	public static String addListHead(String text, int colIndex)
		throws Exception
	{
		String ret = "";
		if (colIndex == -1)
			ret = "<td width='40'>" + text + "</td>";
		else
			ret = "<td>" + text + "</td>";	
		return ret;
	}
	public static String addListHead(
		String text,
		int colIndex,
		String sortType)
		throws Exception
	{
		String ret = "<td>" + text + "</td>";
		return ret;
	}
	public static String addListHeadCheckBox()
	{
		String ret = "<td width=30>选择</td>";
		return ret;
	}

	public static String addTitleHead(String text) throws Exception
	{
		String ret =
			"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
				+ "<tr>"
				+ "<td bgcolor='#666666'>"
				+ "<img src='"
				+ Config.getFrameworkPath()
				+ "/images/blank.gif' width='1' height='1'></td></tr></table>"
				+ "<table width='100%' height='21' border='0' cellpadding='0' cellspacing='0'><tr><td width='25' background='"
				+ Config.getFrameworkPath()
				+ "/images/bar1_leftbg.gif' class='nav'>"
				+ "<img src='"
				+ Config.getFrameworkPath()
				+ "/images/icon_arrow2.gif' width='20' height='18'></td>"
				+ "<td  background='"
				+ Config.getFrameworkPath()
				+ "/images/bar1_leftbg.gif' class='nav'>"
				+ text
				+ "</td><td width='35'><img src='"
				+ Config.getFrameworkPath()
				+ "/images/bar1_center.gif' width='35' height='21'></td>"
				+ "<td width='50%' align='right' background='"
				+ Config.getFrameworkPath()
				+ "/images/bar1_rightbg.gif'>&nbsp;</td></tr></table>";
		return ret;
	}

	public static String addTitleFoot(String text)
	{
		String ret =
			"<table width='100%' border='0' cellpadding='5' cellspacing='0' class='mform-title'><tr><td>"
				+ text
				+ "<span class='notice'></span></td></tr></table>";
		return ret;
	}

	public static String addListDataCheckBoxAble(String value)
	{
		return "";
	}

	public static String addBlankLine(int j) throws Exception
	{
		String str =
			"<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><img src='"
				+ Config.getFrameworkPath()
				+ "/images/blank.gif' width='1' height='1'></td></tr>"
				+ " <tr><td class='bg1'>&nbsp;</td></tr> "
				+ " <tr><td bgcolor='#999999'><img src='<"
				+ Config.getFrameworkPath()
				+ "/images/blank.gif' width='1' height='1'></td></tr></table>";
		for (int i = 1; i < 1; i++)
			str += str;
		return str;
	}

	/*public static String addListHeadCheckBox()
	{
		String str = "<td width=20px>" + "<input type='checkbox' name='check_all' id='check_all' value='1' onclick='selectAll(this.checked,\"ids\")'>"+ "</td>";
		return str;
	}
	public static String addListHead(String text,int colIndex) throws Exception
	{
		return addListHead(text,colIndex,"str");
	}
	
	public static String addListHead(String text,int colIndex,String sortType) throws Exception
	{
		if(colIndex==-1) return "<td height=30px align='center'>"+text+"</td>";
		if(colIndex==-2) return "<td height=30px align='left'>"+text+"</td>";
		return "<td height=30px align='left' nowrap id = 'TD'"+colIndex+"+><span id =divUp"+colIndex+" class=collapsed alt='升序'><img src='"+Config.getFrameworkPath()+"/images/arrow-up.gif' border='0' width='8' height='10'></span><span id = divDown"+colIndex+" class=collapsed alt='降序'><img src='"+Config.getFrameworkPath()+"/images/arrow-down.gif' border='0' width='8' height='10'></span><a href=\"\" onclick=\"SortTable('SortLine',"+colIndex+",'"+sortType+"');return false;\" title=''><font color='white'>"+text+"</font></a></td>";
	}
	
	
	
	public static String addBlankLine(int j) throws Exception
	{
		String str = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><img src='"+Config.getFrameworkPath()+"/images/blank.gif' width='1' height='1'></td></tr>" +
						" <tr><td class='bg1'>&nbsp;</td></tr> "+
						" <tr><td bgcolor='#999999'><img src='<"+Config.getFrameworkPath()+"/images/blank.gif' width='1' height='1'></td></tr></table>";
		for(int i=1;i<1;i++)
			str+=str; 
		return str;
	}
	
	public static String addListHead2(String text,int colIndex) throws Exception
	{
		return addListHead2(text,colIndex,"str");
	}	
	public static String addListHead2(String text,int colIndex,String sortType) throws Exception
	{
		if(colIndex==-1) return "<td height=25px align='center' bgcolor='38aadc'>"+text+"</td>";
		if(colIndex==-2) return "<td height=25px align='left' bgcolor='38aadc'>"+text+"</td>";
		return "<td height=25px align='left' bgcolor='38aadc' id = 'TD'"+colIndex+"+><span id =divUp"+colIndex+" class=collapsed alt='升序'><img src='"+Config.getFrameworkPath()+"/images/arrow-up.gif' border='0' width='8' height='10'></span><span id = divDown"+colIndex+" class=collapsed alt='降序'><img src='"+Config.getFrameworkPath()+"/images/arrow-down.gif' border='0' width='8' height='10'></span><a href=\"\" onclick=\"SortTable('SortLine',"+colIndex+",'"+sortType+"');return false;\" title=''><font color='white'>"+text+"</font></a></td>";
	}*/

	public static String generateDateInputOld(String inputName, String currVal)
		throws Exception
	{
//		String html 
//				= "<script language='javascript'>";
//		html   += "var myDate=new dateSelector();";
//		html   += "myDate.inputName='"+ inputName+"';";
//		html   += "myDate.fulldate='"+ currVal +"';";
//		html   += "myDate.display();";
//		html   += "</script>";
//		return html;  
		String html 
				= "<input type='text' size='15' name='"+ inputName +"' class='texts' value='"+ currVal +"'>";
		html   += "<img src=\"" + Config.getFrameworkPath() + "/calendar/selectdate.gif\" " +
					"onclick=\"selectDate('"+inputName+"', '"+ currVal +"');return false;\">";
			
		return html;
	}
	
	
	public static String generateDateInput(String inputName, String currVal)
	throws Exception
{
	String html 
			= "<input type='text' id='"+ inputName +"' onFocus=\"WdatePicker({maxDate:'2100-01-01',startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})\"  size='18' name='"+ inputName +"' value='"+ currVal +"'>";
	html   += "<img onclick=\"WdatePicker({el:'"+inputName+"',maxDate:'2100-01-01',startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})\"  src=\"" + Config.getFrameworkPath() + "/calendar/selectdate.gif\">";
	
	return html;
}
	
	
	public static String generateDateInputHis(String inputName, String currVal)
	throws Exception
{
//	String html 
//			= "<script language='javascript'>";
//	html   += "var myDate=new dateSelector();";
//	html   += "myDate.inputName='"+ inputName+"';";
//	html   += "myDate.fulldate='"+ currVal +"';";
//	html   += "myDate.display();";
//	html   += "</script>";
//	return html;  
	String html 
			= "<input type='text' size='15' name='"+ inputName +"' class='texts' value='"+ currVal +"'>";
	html   += "<img src=\"" + Config.getFrameworkPath() + "/calendar/selectdate.gif\" " +
				"onclick=\"selectDateHis('"+inputName+"', '"+ currVal +"');return false;\">";
		
	return html;
}
	
	public static String generateDateInput(boolean readonly, String inputName, String currVal)
    throws Exception
    {
//      String html 
//          = "<script language='javascript'>";
//      html   += "var myDate=new dateSelector();";
//      html   += "myDate.inputName='"+ inputName+"';";
//      html   += "myDate.fulldate='"+ currVal +"';";
//      html   += "myDate.display();";
//      html   += "</script>";
//      return html;  
	    String html; 
	    if(readonly){
              html  = "<input type='text' size='15' name='"+ inputName +"' class='texts' value='"+ currVal +"' readonly = 'true'>";
	    }
	    else{
	        html = "<input type='text' size='15' name='"+ inputName +"' class='texts' value='"+ currVal +"'>";
	    }
	    html   += "<img src=\"" + Config.getFrameworkPath() + "/calendar/selectdate.gif\" " +
                    "onclick=\"selectDate('"+inputName+"', '"+ currVal +"');return false;\">";
        
	    return html;
    }
	
	public static String addMessageHeadTitle(String title, boolean needMore,
			String href) throws Exception
	{
//		String str = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
//				+ "<tr>"
//				+ "<td width='129' height='22' background='"
//				+ Config.getWebPath()
//				+ "/images/message/blue-5.gif'>"
//				+ "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
//				+ "<tr>"
//				+ "<td width='23%' height='19'>&nbsp;</td>"
//				+ "<td width='77%' height='19' valign='bottom' class='white-c'>"
//				+ title
//				+ "</td>"
//				+ "</tr>"
//				+ "</table>"
//				+ "</td>"
//				+ (needMore ? "<td width='584' align='right'><a href='"
//						+ Config.getSrv() + "?action_code=" + href
//						+ "'>More...</a></td>"
//						: "<td width='584' align='right'>&nbsp;</td>")
//				+ "</tr>" + "</table>";
//		return str;
		String str =   "<td width='50%' align='center'>"
				+	   "<table width='405' border='0' cellspacing='0' cellpadding='0'>"
		    	+      "<tr>"
		        +		"<td height='21' align='right' valign='middle' background='"+Config.getWebPath()+"/front/net/images/yangshi-1.gif'>"
		        +			"<table width='96%' height='21' border='0' cellpadding='0' cellspacing='0'>"
		        +			"  <tr>"
		        +			"    <td width='31%' valign='middle' class='white'>"+ title +"</td>"
		        +			"	 <td width='58%'>&nbsp;</td>"
		        +			"    <td width='11%'>" 
		        +  (needMore ?	"<a href='"
						+ Config.getSrv() + "?action_code=" + href
						+ "'>"  
		        		+ "<img src='" + Config.getWebPath()
		        		+ "/front/net/images/yangshi-more.gif' width='25' height='10' border='0' /></a></td>"
		        			: "&nbsp;")	
		        +			"  </tr>"
		        +	 "</table>"
		        +	 "</td>"
		        +    "</tr>"
		        +    "<tr>"
		        +	 "	<td height='101' align='center' valign='middle' background='"+Config.getWebPath()+"/front/net/images/yangshi-2.gif'>"
		        +	 "		<table width='95%' border='0' cellspacing='0' cellpadding='0'>";
		return str;
	}
	public static String addMessageFoot(int length) throws Exception
	{
		String str = "";
		for(int i=0; i<5-length; i++)
		{
			str += "<tr><td>&nbsp;</td></tr>";
		}
		
			  str +=  "</table>"
				+	  "    </td>"
				+	  "    </tr>"
				+	  "    <tr>"
				+	  "      <td height='4'><img src='" + Config.getWebPath()
		        + 	  "/front/net/images/yangshi-3.gif' width='405' height='4' /></td>"
				+	  "    </tr>"
				+	  "  </table>"
				+	  "</td>";
		return str;
	}
	
	public static String addMessageHeadTitle(String title) throws Exception
	{
		return addMessageHeadTitle(title, false, "");
	}

}
